let  db = require('../db.js');

//获取所有ai 
exports.getAiSettingList  = async  function () {
  let sql=`
  SELECT *FROM ai_setting
  `  
  let  data  =await db.query(sql);
  return data[0];
}

//更新百度AI配置

exports.updateAISetting  = async  function(id,appId,apiKey,secretKey){

  let sql=`
   update  ai_setting  set  
   appId =:appId,
   apiKey=:apiKey,
   secretKey=:secretKey
   where id=:id
  `
  let  data  = await db.query(sql,{id,appId,apiKey,secretKey});
  return data[0];
}

//插入新的百度AI 配置数据
exports.insertAiSetting  = async  function(appId,apiKey,secretKey){
 let  sql=`
 INSERT  ai_setting  INTO(appId,apiKey,secretKey)
 VALUES(:appId,:apiKey,:secretKey)

 `
 let  data  = await db.query(sql,{appId,apiKey,secretKey});
 return data[0];

}